package com.simple.datax.schedule.impl;

import java.util.List;

import com.alibaba.dubbo.common.logger.Logger;
import com.alibaba.dubbo.common.logger.LoggerFactory;
import com.simple.datax.SimpleResentMessage;
import com.simple.datax.schedule.Processor;
import com.simple.datax.service.DBResentLoaderService;

/** 
 * @Title: ResendScheduledProcessor.java 
 * @Package com.simple.datax.schedule.impl 
 * @Description: TODO(添加描述) 
 * @author Paladin Chen 
 * @date 2013-1-14 上午11:50:04 
 * @version V1.0 
 */
public class ResendScheduledProcessor implements Processor {
	private static final Logger logger = LoggerFactory.getLogger(ResendScheduledProcessor.class);

	private DBResentLoaderService resentLoader;	
	
	private AsyncResentWorker arworker;
	
	private int minutesBefore = 10;
	
	public int getMinutesBefore() {
		return minutesBefore;
	}

	public void setMinutesBefore(int minutesBefore) {
		this.minutesBefore = minutesBefore;
	}

	@Override
	public void process() {
		List<SimpleResentMessage> resl = resentLoader.getNeedResentProcing(minutesBefore);
		
		if(resl == null){
			logger.debug("Resent loader read data size:0 (null)");
			return;
		}
		
		logger.debug("Resent loader read data size:"+resl.size());
		
		for(SimpleResentMessage srm : resl){
			arworker.work(srm);
		}
	}

	public AsyncResentWorker getArworker() {
		return arworker;
	}

	public void setArworker(AsyncResentWorker arworker) {
		this.arworker = arworker;
	}

	public DBResentLoaderService getResentLoader() {
		return resentLoader;
	}

	public void setResentLoader(DBResentLoaderService resentLoader) {
		this.resentLoader = resentLoader;
	}	

}
